package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.RFC;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.GenerateRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.generateRFCPanel.generateRFCSubs.ChooseEditRFCDialog;

public class ChooseEditListListener implements MouseListener {

	private GenerateRFCPanel generateRFCPanel;
	private ChooseEditRFCDialog chooseEditRFCDialog;

	public ChooseEditListListener(GenerateRFCPanel generateRFCPanel,
			ChooseEditRFCDialog editRFCDialog) {

		this.chooseEditRFCDialog = editRFCDialog;
		this.generateRFCPanel = generateRFCPanel;
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {

		if (arg0.getClickCount() == 2) {

			RFC rfc = chooseEditRFCDialog.getDisplayTable().getSelectedRFCinTable();

			this.generateRFCPanel.getDatainputPanel().setupInputFields();
			this.generateRFCPanel.getDatainputPanel().loadExistingData(rfc);

			this.generateRFCPanel.getFunctionPanel().changeButtonstate();

			this.generateRFCPanel.revalidate();
			this.chooseEditRFCDialog.dispose();
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
